#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
typedef long long LL;
const int N = 2e5 + 10;
int arr[N];
LL s[N], s1[N];
int n;
int main()
{
	int t;
	scanf("%d", &t);
	while (t--) {
		scanf("%d", &n);
		memset(s, 0, sizeof(s));
		memset(s1, 0, sizeof(s1));
		for (int i = 1; i <= n; i++) {
			scanf("%d", &arr[i]);
			s[i] = s[i - 1] + arr[i];
		}	
		int ans = 0;
		for (int i = 1; i <= n; i++) {
			if (s[i] == 0) {
				ans++;
			}
		}
		int k = 0;	
		for (int i = 1; i <= n; i++) {
			if (arr[i] == 0) {
				k++;
				s[i] = 0;
			}	
			else {
				s[i] += s[i - 1];
				if (s[i] == 0) {
					k++;
				}
			}
		}
		cout << max(k, ans) << endl;
	}
	return 0;
}